<?php
namespace modules\category;

use modules\category\model\Category as CategoryModel;
class Category{
  protected $category;
  
  public function __construct(CategoryModel $category) {
    $this->category = $category;
  }

  public function data() {
    return $this->category->get();
  }

  public function updateCate($res) {
    return $this->category->where("id", $res['id'])->update([
      "name" => $res['name'],
      "sort" => $res['sort']
    ]);
  }

  public function addCate($res) {
    return $this->category->insert($res);
  }

  public function delCate($res) {
    return $this->category->where('id' ,$res['id'])->delete();
  }
}
?>